package com.bawei.mall.product.service.impl;

import com.bawei.common.redis.service.RedisService;
import com.bawei.mall.product.domain.MallProductAddrs;
import com.bawei.mall.product.mapper.MallProductAddrsMapper;
import com.bawei.mall.product.service.IMallProductAddrsService;
import com.bawei.system.domain.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author：作者姓名
 * @Package：com.bawei.mall.product.service.impl
 * @Project：mall_cloud
 * @name：MallProductAddrsControllerServiceimpl
 * @Date：2024/6/29 13:47
 */
@Service
public class IMallProductAddrsServiceimpl implements IMallProductAddrsService {

    @Autowired
    private MallProductAddrsMapper mallProductAddrsMapper;

    @Autowired
    private RedisService redisService;

    public static final String USER_NAME="user";


    @Override
    public List<MallProductAddrs> selectMallProductAddrs(Long userId) {
        return mallProductAddrsMapper.selectMallProductAddrs(userId);
    }

    @Override
    public void addMallProductAddrs(MallProductAddrs mallProductAddrs) {
        SysUser sysUser = redisService.getCacheObject(USER_NAME);
        mallProductAddrs.setMemberId(sysUser.getUserId());
        mallProductAddrsMapper.addMallProductAddrs(mallProductAddrs);
    }
}
